﻿using System;
using ServiceStack.Redis;
using System.Collections.Generic;
using System.Threading;

namespace CzfSDK
{
	public class RedisPool : ConcurrentCzfPool<CzfRedisClient>
	{
		public static RedisPool current;

		public RedisPool (string host, int port, string defaultDB = "SYSDB", string auth = null, int init = 10, int max = 100, int timeout = 60000)
		{
			current = this;
			this.Init (() => {
				var redis = new RedisClient (host, port);
				if (auth != null)
					throw new Exception ("未实现!!!");
				var client = new CzfRedisClient (redis, defaultDB);
				return client;
				//				return new RedisClient(host, port, auth, 0);
			}, (CzfRedisClient client) => {
				if(client != null)
					client.Close();
			}, init, max, timeout);
		}
	}
}

